package pattern.mediator;

public class Test {
    public static void main(String[] args) {
        // 先创建三个角色：中介公司，房主、租客
        MediatorCompany mediatorCompany = new MediatorCompany();
        // 房主和租客在同一家中介公司
        HouseOwner houseOwner = new HouseOwner("房主张三", mediatorCompany);
        Tenant tenant = new Tenant("租客李四", mediatorCompany);
        // 中介公司获取租客和房主信息
        mediatorCompany.setHouseOwner(houseOwner);
        mediatorCompany.setTenant(tenant);
        // 租客和房主都在这家中介公司发布消息，获取到对应的消息
        tenant.connection(tenant.name + "想租套一");
        houseOwner.connection(houseOwner.name + "这里有！");
    }
}
